import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-10-03
 * Time: 12:50
 */
public class TestDemo {
    public static void main(String[] args) {
        int[] arr = {5, 2, 8, 4, 9, 1, 12, -33};
//		for循环进行比对相邻的两个数的大小

        for(int i=0;i<arr.length-1;i++){
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j]>arr[j+1]){
                    int num = arr[j];//提取值用于后期覆盖
                    arr[j] = arr[j+1];//赋值
                    arr[j+1] = num;//把之前提取的值赋值到对应地方
                };
            }
        }
        System.out.println(Arrays.toString(arr));
    }







}
